<?php

namespace App\Models;

use Hyn\Tenancy\Traits\UsesTenantConnection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\Models\AssetBundle
 *
 * @property int $id
 * @property string $name
 * @property string $description
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\AssetBundleItem[] $items
 * @property-read int|null $items_count
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AssetBundle fuzzyFilter($queryString)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AssetBundle newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AssetBundle newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\AssetBundle onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AssetBundle query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AssetBundle whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AssetBundle whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AssetBundle whereDescription($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AssetBundle whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AssetBundle whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AssetBundle whereUpdatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Models\AssetBundle withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\AssetBundle withoutTrashed()
 * @mixin \Eloquent
 */
class AssetBundle extends Model
{
    use SoftDeletes, UsesTenantConnection;
    protected $guarded = [];

    protected $with = [];
    public function items() {
        return $this->hasMany(AssetBundleItem::class);
    }
    public function scopeFuzzyFilter($query, $queryString) {
        $likeStr = '%' . $queryString . '%';
        $query->where('name', 'like', $likeStr)
            ->orWhere('description', 'like', $likeStr);
        return $query;
    }

}
